package dt.board.notice;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;


import java.io.Reader;
import java.io.IOException;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

public class noticeDeleteAction extends ActionSupport implements SessionAware{
	private Map session;
	
	public static Reader reader; 
	public static SqlMapClient sqlMapper; 
	
	
	private noticeBoardVO paramClass = new noticeBoardVO();
	private noticeBoardVO resultClass = new noticeBoardVO();
	
	private int currentPage; 
	
	private int no; 
	
	public noticeDeleteAction() throws IOException{
		
		reader = Resources.getResourceAsReader("sqlMapConfig.xml"); 
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader); 
		
		reader.close(); 
			
	}
	
	public String execute() throws Exception{
		
		resultClass = (noticeBoardVO) sqlMapper.queryForObject("notice.selectOne", getNo()); 
		paramClass.setNo(getNo());
		sqlMapper.update("notice.deleteBoard", paramClass); 
		
		return SUCCESS; 
	}
	
	

	public noticeBoardVO getParamClass() {
		return paramClass;
	}

	public void setParamClass(noticeBoardVO paramClass) {
		this.paramClass = paramClass;
	}

	public noticeBoardVO getResultClass() {
		return resultClass;
	}

	public void setResultClass(noticeBoardVO resultClass) {
		this.resultClass = resultClass;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public Map getSession() {
		return session;
	}

	public void setSession(Map session) {
		this.session = session;
	}
	
	
}
